package net.xiduth.game.player.dialogues.auto;

import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * @author Oracle
 * 
 * Handles PvM Rewards and info.
 *
 */
public class PvMRewards extends Dialogue {

	int npcId;

	@Override
	public void start() {
		npcId = 1063;
		sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "Never mind.");
		stage = 0;
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "Never mind.");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				sendNPCDialogue(npcId, CALM_TALKING, "You currently have <col=ff0000>" + player.getPvMPoints() + "</col> PvM points.");
				stage = -1;
				break;
			case OPTION_2:
				sendOptionsDialogue("PvM Rewards", "Darklight (500 pts.)", "Dragon claws (5000 pts.)", "Overload bundle (200 pts.)" , "Thok's sword (30000 pts.)", "Next page...");
				stage = 4;
				break;
			case OPTION_3:
				sendNPCDialogue(npcId, LISTEN_LAUGH, "Each monster you kill will give you up to 5 PvM Points, the points can then be exchanged here.");
				stage = -1;
				break;
			case OPTION_4:
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			}
			break;
		case 3:
			end();
			break;
		case 4:
			switch(option) {
		case OPTION_1: //6746 darklight
				if (player.getPvMPoints() >= 500) {
				player.getBank().addItem(6746, 1, true);
				player.setPvMPoints(player.getPvMPoints()
						- 500);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 6746, 1);
				player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 500 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2: //14484 - dragon claws
			if (player.getPvMPoints() >= 5000) {
			player.getBank().addItem(14484, 1, true);
			player.setPvMPoints(player.getPvMPoints()
					- 5000);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 14484, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 5,000 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3: //15332 overload bundle
			if (player.getPvMPoints() >= 200) {
			player.getBank().addItem(15332, 25, true);
			player.setPvMPoints(player.getPvMPoints()
					- 200);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 15332, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 200 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4: //20821 thok sword
			//WAS 13727 stardust (125x) 
			if (player.getPvMPoints() >= 30000) {
			player.getBank().addItem(20821, 1, true);
			player.setPvMPoints(player.getPvMPoints()
					- 30000);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 20821, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank. Remember your ::stabilizer!");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 30,000 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getDialogueManager().startDialogue("Page2PvM");
			//sendOptionsDialogue("PvM Rewards - Page 2", "50x Planks (25 pts.)", "50x Steel nails (25 pts.)", "50x Mahogany planks (30 pts.)" , "250x Stardust (200 pts.)", "Never mind.");
			//stage = 5;
			break;
		case 5:
			switch(option) {
		case OPTION_1: //960 planks
				if (player.getPvMPoints() >= 25) {
				player.getBank().addItem(960, 50, true);
				player.setPvMPoints(player.getPvMPoints()
						- 25);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 960, 1);
				player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 25 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2: //1539 steel nails
			if (player.getPvMPoints() >= 25) {
			player.getBank().addItem(1539, 50, true);
			player.setPvMPoints(player.getPvMPoints()
					- 25);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 1539, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 25 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3: //8782 mahogany planks
			if (player.getPvMPoints() >= 30) {
			player.getBank().addItem(8782, 50, true);
			player.setPvMPoints(player.getPvMPoints()
					- 30);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 8782, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 30 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4: //13727 stardust (125x)
			if (player.getPvMPoints() >= 200) {
			player.getBank().addItem(13727, 250, true);
			player.setPvMPoints(player.getPvMPoints()
					- 200);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 13727, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendNPCDialogue(npcId, 9827, "You need 200 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getInterfaceManager().closeChatBoxInterface();
			break;
		case 69:
			player.getControlerManager().startControler("DarkInvasion");
			break;
		default:
			end();
			break;
		}}}}

	@Override
	public void finish() {

	}

}
